﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
					xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
					xmlns:Root="clr-namespace:Elysium.Theme">

	<ResourceDictionary.MergedDictionaries>
		<ResourceDictionary Source="/Elysium.Theme;component/Themes/SharedResources.xaml"/>
	</ResourceDictionary.MergedDictionaries>
	
	<Style TargetType="{x:Type CheckBox}">
		
		<Setter Property="Background" Value="{StaticResource Transparent}"/>
		<Setter Property="BorderBrush" Value="{StaticResource ForegroundMiddlelight}"/>
		<Setter Property="BorderThickness" Value="{x:Static Root:Parameters.DefaultThickness}"/>
		<Setter Property="Foreground" Value="{StaticResource Foreground}"/>
		<Setter Property="FontFamily" Value="{x:Static Root:Parameters.FontFamily}"/>
		<Setter Property="FontSize" Value="{x:Static Root:Parameters.ContentFontSize}"/>
		<Setter Property="FontWeight" Value="Normal"/>

		<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisualStyle}"/>

		<Setter Property="HorizontalContentAlignment" Value="Left"/>
		<Setter Property="VerticalContentAlignment" Value="Center"/>
		<Setter Property="Padding" Value="{x:Static Root:Parameters.BoldPadding}"/>

		<Setter Property="OverridesDefaultStyle" Value="True"/>
		<Setter Property="SnapsToDevicePixels" Value="True"/>

		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type CheckBox}">
					
					<Grid Background="{StaticResource Transparent}"
						  Margin="{TemplateBinding Padding}"
						  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
						<BulletDecorator Background="{StaticResource Transparent}"
										 TextBlock.Foreground="{TemplateBinding Foreground}"
										 TextBlock.FontFamily="{TemplateBinding FontFamily}"
										 TextBlock.FontSize="{TemplateBinding FontSize}"
										 TextBlock.FontWeight="{TemplateBinding FontWeight}"
										 FlowDirection="{TemplateBinding FlowDirection}">
							<BulletDecorator.Bullet>
								<Border Background="{TemplateBinding Background}"
										BorderBrush="{TemplateBinding BorderBrush}"
										BorderThickness="{TemplateBinding BorderThickness}"
										Width="{TemplateBinding Root:Parameters.BulletDecoratorSize}" Height="{TemplateBinding Root:Parameters.BulletDecoratorSize}">
									<Grid Background="{StaticResource Transparent}">
										<Path x:Name="CheckBullet"
											  Fill="{StaticResource Transparent}"
											  Stroke="{StaticResource ForegroundLowlight}"
											  StrokeThickness="{x:Static Root:Parameters.BoldStrokeThickness}"
											  Stretch="Fill"
											  Visibility="Collapsed"
											  HorizontalAlignment="Center" VerticalAlignment="Center"
											  Width="{TemplateBinding Root:Parameters.CheckBoxBulletSize}" Height="{TemplateBinding Root:Parameters.CheckBoxBulletSize}">
											<Path.Data>
												<GeometryGroup>
													<LineGeometry StartPoint="0,3" EndPoint="4,8"/>
													<LineGeometry StartPoint="4,8" EndPoint="8,0"/>
												</GeometryGroup>
											</Path.Data>
										</Path>
										<Path x:Name="IndeterminateBullet"
											  Fill="{StaticResource ForegroundLowlight}"
											  StrokeThickness="0"
											  Stretch="Fill"
											  Visibility="Collapsed"
											  Margin="2"
											  HorizontalAlignment="Center" VerticalAlignment="Center"
											  Width="{TemplateBinding Root:Parameters.CheckBoxBulletSize}" Height="{TemplateBinding Root:Parameters.CheckBoxBulletSize}">
											<Path.Data>
												<GeometryGroup>
													<RectangleGeometry Rect="0,0,1,1"/>
												</GeometryGroup>
											</Path.Data>
										</Path>
									</Grid>
								</Border>
							</BulletDecorator.Bullet>
							<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
											  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
											  RecognizesAccessKey="True">
								<ContentPresenter.Margin>
									<Thickness Left="{x:Static Root:Parameters.BoldPaddingValue}"
											   Top="0"
											   Right="0"
											   Bottom="0"/>
								</ContentPresenter.Margin>
							</ContentPresenter>
						</BulletDecorator>
					</Grid>
					
					<ControlTemplate.Triggers>						
						<Trigger Property="IsChecked" Value="True">
							<Setter TargetName="CheckBullet" Property="Visibility" Value="Visible"/>
						</Trigger>						
						<MultiTrigger>
							<MultiTrigger.Conditions>
								<Condition Property="IsThreeState" Value="True"/>
								<Condition Property="IsChecked" Value="{x:Null}"/>
							</MultiTrigger.Conditions>
							<MultiTrigger.Setters>
								<Setter TargetName="IndeterminateBullet" Property="Visibility" Value="Visible"/>
							</MultiTrigger.Setters>
						</MultiTrigger>						
						<Trigger Property="IsEnabled" Value="False">
							<Setter TargetName="CheckBullet" Property="Path.Stroke" Value="{StaticResource Disabled}"/>
							<Setter TargetName="IndeterminateBullet" Property="Path.Fill" Value="{StaticResource Disabled}"/>
						</Trigger>						
					</ControlTemplate.Triggers>
					
				</ControlTemplate>
			</Setter.Value>
		</Setter>
		
		<Style.Triggers>			
			<Trigger Property="IsMouseOver" Value="True">
				<Setter Property="Background" Value="{StaticResource ForegroundHighlight}"/>
				<Setter Property="BorderBrush" Value="{StaticResource ForegroundMiddlelight}"/>
			</Trigger>
			<Trigger Property="IsPressed" Value="True">
				<Setter Property="Background" Value="{StaticResource ForegroundHighlight}"/>
				<Setter Property="BorderBrush" Value="{StaticResource ForegroundLowlight}"/>
			</Trigger>
			<Trigger Property="IsEnabled" Value="False">
				<Setter Property="Background" Value="{StaticResource Transparent}"/>
				<Setter Property="BorderBrush" Value="{StaticResource Disabled}"/>
				<Setter Property="Foreground" Value="{StaticResource Disabled}"/>
			</Trigger>
		</Style.Triggers>	
		
	</Style>

</ResourceDictionary>